﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace Ledict.ConditionExtract.BLL
{
   public  class StaticCache
    {
   public  static   Dictionary<string, DataTable> plotchildDict = new Dictionary<string, DataTable>();//节点信息
   public static Dictionary<string, DataTable> RelationStiuationDict = new Dictionary<string, DataTable>();//节点相关的所有父子

   public static Dictionary<string, DataTable> AllBelowStiuationDict = new Dictionary<string, DataTable>();//节点相关标签
  

   public static Dictionary<string, DataTable> ReasonLabelDict = new Dictionary<string, DataTable>();//节点相关标签


   protected ProcessDataSource datas = new ProcessDataSource();
   protected XmlLabel_LabelRelBLL xmlLabel_LabelRelBLL = new XmlLabel_LabelRelBLL();
   /// <summary>
   /// 得到案由的所有下级
   /// </summary>
   /// <param name="conditon"></param>
   /// 
   public DataTable GetHeadwordData(string headwordid)
   {
       DataTable conditiondt;//下级
       if (StaticCache.plotchildDict.ContainsKey(headwordid))
       {
           conditiondt = StaticCache.plotchildDict[headwordid];
       }
       else
       {
           order = 0;
           conditiondt = datas.GetCauseDataSource("");
           conditiondt.Columns.Add("TotalOrder", typeof(int));
           GetHeadwordDataAndOrder(headwordid, conditiondt);
          // conditiondt = datas.GetCauseDataSource(headwordid);
           StaticCache.plotchildDict.Add(headwordid, conditiondt);
       }
       return conditiondt;
     

   }
   int order=0;
   
   public void  GetHeadwordDataAndOrder(string headwordid,DataTable dt)
   {
       DataTable conditiondt = datas.GetCauseDataSource(headwordid);
       conditiondt.Columns.Add("TotalOrder", typeof(int));
       for (int i = 0; i < conditiondt.Rows .Count ; i++)
       {
           conditiondt.Rows[i][conditiondt.Columns.Count - 1] = order++;
           dt.ImportRow((DataRow)conditiondt.Rows[i]);
           GetHeadwordDataAndOrder(conditiondt.Rows[i]["CC_ID"].ToString(),dt);
       }
   }








       /// <summary>
       /// 得到相关节点，匹配挖空
       /// </summary>
       /// <param name="CC_ID"></param>
       /// <returns></returns>
   public DataTable GetRelLabel(string CC_ID)
   {
       DataTable conditiondt;//下级
       if (StaticCache.ReasonLabelDict.ContainsKey(CC_ID))
       {
           conditiondt = StaticCache.ReasonLabelDict[CC_ID];
       }
       else
       {
           conditiondt = xmlLabel_LabelRelBLL.GetList(CC_ID);
           StaticCache.ReasonLabelDict.Add(CC_ID, conditiondt);
       }
       return conditiondt;
   }










    }
}
